/*     */ package com.lmpop.trade.ti_address;
/*     */ 
/*     */ import com.lmpop.frame.QueryList;
/*     */ import com.lmpop.frame.SysMap;
/*     */ import com.lmpop.frame.TradeInterf;
/*     */ import com.lmpop.frame.dao.DbmInterf;
/*     */ import com.lmpop.frame.exp.ApplicationException;
/*     */ import java.io.PrintStream;
/*     */ import java.util.Hashtable;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class Ti_addressInfo
/*     */   implements TradeInterf
/*     */ {
/*     */   QueryList queryList;
/*     */ 
/*     */   public Ti_addressInfo()
/*     */   {
/*  18 */     this.queryList = new QueryList();
/*     */   }
/*     */ 
/*     */   public SysMap insert(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  27 */     Ti_address ti_address = new Ti_address();
/*  28 */     if ((map.getString("addr_id") != null) && (!"".equals(map.getString("addr_id"))))
/*  29 */       ti_address.setAddr_id(map.getString("addr_id").toString());
/*     */     else {
/*  31 */       ti_address.setAddr_id(map.getString("_addr_id").toString());
/*     */     }
/*  33 */     ti_address.setConsignee(map.getString("consignee"));
/*  34 */     ti_address.setLevel_no(Integer.parseInt(map.getString("level_no")));
/*  35 */     ti_address.setEmail(map.getString("email"));
/*  36 */     ti_address.setArea_attr(map.getString("area_attr"));
/*  37 */     ti_address.setAddress(map.getString("address"));
/*  38 */     ti_address.setPost_code(map.getString("post_code"));
/*  39 */     ti_address.setTel(map.getString("tel"));
/*  40 */     ti_address.setCellphone(map.getString("cellphone"));
/*     */ 
/*  42 */     ti_address.setBest_time(map.getString("best_time"));
/*  43 */     ti_address.setUser_id(map.getString("user_id"));
/*  44 */     ti_address.setCust_id(map.getString("cust_id"));
/*     */ 
/*  46 */     ti_address.setIn_date(map.getString("in_date"));
/*     */ 
/*  48 */     String result_code = "0";
/*     */     try {
/*  50 */       int count = checkAddressIsExistByCustId(ti_address);
/*  51 */       if (count == 0)
/*  52 */         insert(dbmMgr, ti_address);
/*     */       else
/*  54 */         result_code = "1";
/*     */     } catch (ApplicationException e) {
/*  56 */       e.printStackTrace();
/*  57 */       result_code = "1";
/*     */     }
/*  59 */     map.setString("result_code", result_code);
/*  60 */     return map;
/*     */   }
/*     */ 
/*     */   public void insert(DbmInterf dbmMgr, Ti_address ti_address)
/*     */     throws ApplicationException
/*     */   {
/*  69 */     dbmMgr.update("insertTi_address", ti_address);
/*     */   }
/*     */ 
/*     */   public SysMap insertMaxLevel(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  78 */     Ti_address ti_address = new Ti_address();
/*  79 */     String addr_id = map.getString("addr_id");
/*  80 */     List addrList = getListByPk(addr_id);
/*  81 */     if ((addrList != null) && (addrList.size() > 0))
/*     */     {
/*     */       try
/*     */       {
/*  85 */         delete(dbmMgr, addr_id);
/*     */       }
/*     */       catch (ApplicationException e)
/*     */       {
/*  89 */         e.printStackTrace();
/*     */       }
/*     */     }
/*     */ 
/*  93 */     ti_address.setAddr_id(addr_id);
/*  94 */     ti_address.setConsignee(map.getString("consignee"));
/*  95 */     String user_id = map.getString("user_id");
/*  96 */     String cust_id = map.getString("cust_id");
/*  97 */     int infolevel = getMaxLevel(user_id);
/*  98 */     ti_address.setLevel_no(infolevel);
/*  99 */     ti_address.setEmail("");
/* 100 */     ti_address.setArea_attr(map.getString("area_attr"));
/* 101 */     ti_address.setAddress(map.getString("address"));
/* 102 */     ti_address.setPost_code(map.getString("post_code"));
/* 103 */     ti_address.setTel(map.getString("tel"));
/* 104 */     ti_address.setCellphone(map.getString("cellphone"));
/*     */ 
/* 106 */     ti_address.setBest_time("");
/* 107 */     ti_address.setUser_id(user_id);
/* 108 */     ti_address.setCust_id(map.getString("cust_id"));
/*     */ 
/* 110 */     String result_code = "0";
/*     */     try {
/* 112 */       insert(dbmMgr, ti_address);
/*     */     } catch (ApplicationException e) {
/* 114 */       e.printStackTrace();
/* 115 */       result_code = "1";
/*     */     }
/* 117 */     map.setString("result_code", result_code);
/* 118 */     return map;
/*     */   }
/*     */ 
/*     */   public Hashtable getOneAddrByLevel(String user_id)
/*     */   {
/* 128 */     Hashtable oneMap = new Hashtable();
/* 129 */     List oneList = this.queryList.getList("getOneTi_addressMaxLevel", user_id);
/* 130 */     if ((oneList != null) && (oneList.size() > 0))
/*     */     {
/* 132 */       oneMap = (Hashtable)oneList.get(0);
/*     */     }
/* 134 */     return oneMap;
/*     */   }
/*     */ 
/*     */   public int getMaxLevel(String user_id)
/*     */   {
/* 147 */     List list = this.queryList.getList("getMaxTi_addressLevel", user_id);
/* 148 */     int infolevel = 0;
/* 149 */     if ((list != null) && (list.size() > 0))
/*     */     {
/* 151 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 152 */       if ((newsMap.get("infolevel") != null) && (!newsMap.get("infolevel").toString().equals("")))
/*     */       {
/* 154 */         infolevel = Integer.parseInt(newsMap.get("infolevel").toString()) + 1;
/*     */       }
/*     */     }
/* 157 */     return infolevel;
/*     */   }
/*     */ 
/*     */   public SysMap delete(DbmInterf dbmMgr, SysMap map)
/*     */   {
/* 169 */     String pkid_string = map.getString("pkid");
/* 170 */     String result_code = "0";
/*     */     try {
/* 172 */       if (!pkid_string.equals("")) {
/* 173 */         String[] pkStr = pkid_string.split("\\|");
/* 174 */         for (int i = 0; i < pkStr.length; i++) {
/* 175 */           if (pkStr[i].equals("")) continue; delete(dbmMgr, pkStr[i]);
/*     */         }
/*     */       }
/*     */     } catch (ApplicationException e) {
/* 179 */       e.printStackTrace();
/* 180 */       result_code = "1";
/*     */     }
/* 182 */     map.setString("result_code", result_code);
/* 183 */     return map;
/*     */   }
/*     */ 
/*     */   public void delete(DbmInterf dbmMgr, String pkid)
/*     */     throws ApplicationException
/*     */   {
/* 192 */     dbmMgr.update("deleteTi_address", pkid);
/*     */   }
/*     */ 
/*     */   public SysMap update(DbmInterf dbmMgr, SysMap map)
/*     */   {
/* 201 */     Ti_address ti_address = new Ti_address();
/* 202 */     if (map.getString("addr_id") != null)
/* 203 */       ti_address.setAddr_id(map.getString("addr_id").toString());
/* 204 */     if (map.getString("consignee") != null)
/* 205 */       ti_address.setConsignee(map.getString("consignee"));
/* 206 */     if ((map.getString("level_no") != null) && (!"".equals(map.getString("level_no"))))
/* 207 */       ti_address.setLevel_no(Integer.parseInt(map.getString("level_no")));
/* 208 */     if (map.getString("email") != null)
/* 209 */       ti_address.setEmail(map.getString("email"));
/* 210 */     if (map.getString("area_attr") != null)
/* 211 */       ti_address.setArea_attr(map.getString("area_attr"));
/* 212 */     if (map.getString("address") != null)
/* 213 */       ti_address.setAddress(map.getString("address"));
/* 214 */     if (map.getString("post_code") != null)
/* 215 */       ti_address.setPost_code(map.getString("post_code"));
/* 216 */     if (map.getString("tel") != null)
/* 217 */       ti_address.setTel(map.getString("tel"));
/* 218 */     if (map.getString("cellphone") != null)
/* 219 */       ti_address.setCellphone(map.getString("cellphone"));
/* 220 */     if (map.getString("best_time") != null)
/* 221 */       ti_address.setBest_time(map.getString("best_time"));
/* 222 */     if (map.getString("user_id") != null)
/* 223 */       ti_address.setUser_id(map.getString("user_id"));
/* 224 */     if (map.getString("cust_id") != null)
/* 225 */       ti_address.setCust_id(map.getString("cust_id"));
/* 226 */     if (map.getString("in_date") != null) {
/* 227 */       ti_address.setIn_date(map.getString("in_date"));
/*     */     }
/*     */ 
/* 231 */     String result_code = "0";
/*     */     try {
/* 233 */       int count = checkAddressIsExistByCustId(ti_address);
/* 234 */       if (count > 0) {
/* 235 */         delete(dbmMgr, ti_address.getAddr_id());
/* 236 */         insert(dbmMgr, ti_address);
/*     */       } else {
/* 238 */         update(dbmMgr, ti_address);
/*     */       }
/*     */     }
/*     */     catch (ApplicationException e) {
/* 242 */       e.printStackTrace();
/* 243 */       result_code = "1";
/*     */     }
/* 245 */     map.setString("result_code", result_code);
/* 246 */     return map;
/*     */   }
/*     */ 
/*     */   public void updateByuser_id(DbmInterf dbmMgr, Ti_address ti_address) throws ApplicationException {
/* 250 */     dbmMgr.update("updateTi_addressByUser_id", ti_address);
/*     */   }
/*     */ 
/*     */   public void update(DbmInterf dbmMgr, Ti_address ti_address)
/*     */     throws ApplicationException
/*     */   {
/* 259 */     System.out.println("执行" + ti_address.getAddress() + "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
/* 260 */     dbmMgr.update("updateTi_address", ti_address);
/*     */   }
/*     */ 
/*     */   public List getListByPage(Object obj, int start, int limit)
/*     */   {
/* 270 */     Map ti_address = (Hashtable)obj;
/* 271 */     if (start == 0)
/* 272 */       start = 0;
/*     */     else {
/* 274 */       start = (start - 1) * limit;
/*     */     }
/* 276 */     ti_address.put("start", Integer.valueOf(start));
/* 277 */     ti_address.put("limit", Integer.valueOf(limit));
/*     */ 
/* 279 */     return this.queryList.getList("getListByTi_addressPage", ti_address);
/*     */   }
/*     */ 
/*     */   public int getCountByObj(Object obj)
/*     */   {
/* 291 */     Map ti_address = (Hashtable)obj;
/*     */ 
/* 293 */     List list = this.queryList.getList("getCountByObjTi_address", ti_address);
/* 294 */     int count = 0;
/* 295 */     if ((list != null) && (list.size() > 0)) {
/* 296 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 297 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 298 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 301 */     return count;
/*     */   }
/*     */ 
/*     */   public List getListByPk(String pk)
/*     */   {
/* 311 */     return this.queryList.getList("getTi_addressByPk", pk);
/*     */   }
/*     */ 
/*     */   public List getAddressListByUserID(Object obj)
/*     */   {
/* 321 */     Map ti_address = (Hashtable)obj;
/* 322 */     Map params = new Hashtable();
/*     */ 
/* 324 */     String user_id = "";
/* 325 */     if (ti_address.get("user_id") != null) user_id = ti_address.get("user_id").toString();
/* 326 */     if ((user_id != null) && (!user_id.equals(""))) params.put("user_id", user_id);
/*     */ 
/* 328 */     return this.queryList.getList("getAddressListByUserID", params);
/*     */   }
/*     */ 
/*     */   public int checkAddressIsExistByCustId(Ti_address ti_address) {
/* 332 */     int count = 0;
/* 333 */     List list = this.queryList.getList("checkAddressIsExistByCustId", ti_address);
/* 334 */     count = Integer.parseInt(((Hashtable)list.get(0)).get("count").toString());
/* 335 */     return count;
/*     */   }
/*     */   public String getEmailByPk(String pk) {
/* 338 */     List list = this.queryList.getList("getaddressEmailByPk", pk);
/* 339 */     if ((list != null) && (list.size() > 0)) {
/* 340 */       return ((Hashtable)list.get(0)).get("email").toString();
/*     */     }
/* 342 */     return "0";
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.ti_address.Ti_addressInfo
 * JD-Core Version:    0.6.0
 */